package com.shop.dao;

import com.shop.pojo.User;
import com.shop.util.DBUtil;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanHandler;

import java.sql.SQLException;


public class UserDaoImpl implements UserDao {
    private QueryRunner runner =new QueryRunner(DBUtil.getDateSource());

    @Override
    public User findByusername(String username) {
       String sql = "select * from tb_user where username = ?";
        try {
            User user  = runner.query(sql, new BeanHandler<User>(User.class), username);
            return user;
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return null;
    }


}
